<?php
declare (strict_types = 1);

namespace app\command;

use app\model\Device;
use app\model\DeviceRecords;
use app\model\DeviceRent as DeviceRentModel;
use Stomp\Client;
use Stomp\Exception\StompException;
use Stomp\Network\Observer\Exception\HeartbeatException;
use Stomp\Network\Observer\ServerAliveObserver;
use Stomp\StatefulStomp;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Db;
use think\facade\Log;
class DeviceRent extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('rent')
            ->setDescription('the rent command');
    }

    protected function execute(Input $input, Output $output)
    {
        //未激活 已激活 已过期

        $device = Device::where('project_id','>',0)->where('is_rent',2)->where('use_status','已激活')->select();
        writeLog($device);
        foreach ($device as $v){
            DeviceRentModel::create([
                'company_id' => $v['company_id'],
                'project_id' => $v['project_id'],
                'device_id' => $v['id'],
                'title' => $v['title'],
                'id_no'=> $v['id_no'],
                'name_no'=> $v['name_no'],
                'price'=> $v['rent_price'],
            ]);
        }

    }

}
